<?php 
    Yii::import("application.models.dao.auction.AuctionDao");
?>
<li class="auction-item auction-item-category" auction-id="<?php echo CHtml::value($data, 'auction_id') ?>"
    attribute-data-last_time=0 attribute-data-end_time=<?php echo CHtml::value($data, 'end_time') ?>>
    <div class="auction-image-cell">
        <a class="auction-detail-link" attribute="url"
           href="<?php echo !empty($data->url) ? $data->url : null ?>">
            <div class="auction-image-box">
                <div style="position: absolute;right:3px;z-index:2000;top:3px;display:<?php  echo $this->breadcrumbs[0]=="Closed"?"inherit":"none"?>;"  class="auction-sold-img">
                    <img style="height:50px;width:50px;" alt="Sold"  src="<?php echo Yii::app()->baseUrl."/images/sold.png"?>" />
                </div>
                <?php 
                     $auctionId=CHtml::value($data, 'auction_id');
                     if($auctionId!==null){
                         $dao=new AuctionDao();
                         $dao->find($auctionId);
                         $specialAuctions=array(3,4,5);
                         $specialAuctionsTitle=array("3"=>'BRONZE',"4"=>'SILVER',"5"=>"GOLD");
                         $specialAuctionsColor=array("3"=>'#89621f',"4"=>'#a9a9a9',"5"=>"#d5b32a");
                         $color="#fff";
                         $title="";
                         if (in_array($dao->type, $specialAuctions)){
                             $color=$specialAuctionsColor[$dao->type];
                             $title=$specialAuctionsTitle[$dao->type];
                         }elseif ($dao->rookie){
                             $color="#ef0000";
                             $title="ROOKIE";
                         }
                         if (in_array($dao->type, $specialAuctions) || $dao->rookie){
                         ?>
                        <div style="position:absolute;border:solid 1px  <?php echo $color?>;right:10px;top:10px;padding:3px;color:<?php echo $color?>;font-size:10px;font-weight:bold;">
                            <?php echo $title?>
                        </div>
                    <?php }}?>
            <span class="auction-increment">
                <div class="auction-status-show">

                </div>
                <img class="auction-increment-ico"
                     src='<?php 
                     $auctionId=CHtml::value($data, 'auction_id');
                     
		             $rookie = 0;
                     if($auctionId!==null) {
                         $rookie = AuctionPool::getRookieAuction($auctionId);
                     }
		     
                     if (intval($rookie)>0){
                         echo Yii::app()->resource->path('img').'/increment/rookie.png';
                     }else {
                        echo Yii::app()->resource->path('img').'/increment/increment-cent-1.png';
                     }
                     ?>'/>
            </span>
                <?php 
                    if($this->breadcrumbs[0]=="Closed"){
                ?>
               <img class="auction-image"  attribute="images"   aid=<?php echo CHtml::value($data,'id')?>
			src='<?php  echo   null!=CHtml::value($data,'id')?AuctionInfo::getImageUrl(CHtml::value($data,'id')):"" ?>'
                     onerror="this.src='<?php echo Yii::app()->resource->path('img') . '/no-image.png' ?>'"/>     
                <?php }else{?>
                <img class="auction-image" attribute="images"
                     src='<?php echo !empty($data->images) ? $data->images : Yii::app()->resource->path('img') . '/no-image.png' ?>'
                     onerror="this.src='<?php echo Yii::app()->resource->path('img') . '/no-image.png' ?>'"/>
                <?php }?>
            </div>
        </a>
    </div>
    <div class="auction-info-cell">
        <a class="auction-detail-link" attribute="url"
        <?php 
                if($this->breadcrumbs[0]=="Closed"){
        ?>
                href="<?php echo Yii::app()->params['site_url'].'/index/detail?auction_id='.CHtml::value($data,'id') ?>" 
        <?php 
                }elseif ($this->breadcrumbs[0]=="Live" || $this->breadcrumbs[0]=="feature"){ 
        ?>
                href="<?php echo !empty($data->url) ? $data->url : null ?>"
	    <?php }?>
	    >
           
            <div class="auction-title" attribute="title">
                <a  style="color: #e41e28;text-decoration:none;" 
                    target="_blank"   href="<?php echo !empty($data->url) ? $data->url : null ?>">
                        <?php echo CHtml::value($data, 'title') ?>
                </a>
            </div>
        </a>
        <div class="auction-winner-cell">
            <div class="auction-winner" attribute="winner_customer">
                
                <?php 
                    $winnerName = CHtml::value($data,'winner_name');
                    $winnerNameClosed= AuctionInfo::model()->getCustomer(CHtml::value($data,'winner_id'));
                    $avatar = CHtml::value($data,'winner_avatar')?:'/no-avatar.png';
                ?>
                <div class="winner-no-customer <?php echo empty($winnerName||$winnerNameClosed)?null:'hide'?>">        	
                	No bidders yet
                </div>
                <div class="winner-customer <?php echo empty($winnerName||$winnerNameClosed)?'hide':null?>">
                	<!--<img class="auction-winner-avatar img-circle" attribute="winner_avatar" src='<?php echo $avatar?>' />-->
                	<span class="auction-winner-name" attribute="winner_name" attribute-animation="flash-value" animation-time=3 ><?php echo $winnerName?$winnerName:$winnerNameClosed?$winnerNameClosed->user_name:"";?></span>
                </div>
                <!-- 
                
                 -->
            </div>
            <?php 
                if($this->breadcrumbs[0]=="Closed"){?>
                    <div class="auction-last-time" attribute="last_date">
                    Closed
                    </div>
            <?php }elseif ($this->breadcrumbs[0]=="Live"){?>       
                 
                    <div class="auction-last-time" attribute="last_date">
                    -- : -- : --
                    </div>
            <?php }else{?>
            		<div class="auction-last-time" attribute="last_date">
                    -- : -- : --
                    </div>
            <?php }?>
            
        </div>
        <div class="auction-item-footer">
            <div class="auction-winner-price-cell">
                <span class="auction-winner-price" attribute="winner_price" attribute-animation="flash-value"
                      animation-time=3><?php echo CHtml::value($data,'winner_price','$0.00')?></span>
            </div>
            <div class="bid-auction-cell">
                <?php 
                if($this->breadcrumbs[0]=="Closed"){
                    
                }elseif ($this->breadcrumbs[0]=="Live"){
                    $this->widget('application.components.widgets.CBidAuctionBtn',array(
                        'auctionId' => CHtml::value($data, 'auction_id')
                    ));
                }else{
                	$this->widget('application.components.widgets.CBidAuctionBtn',array(
                			'auctionId' => CHtml::value($data, 'auction_id')
                	));
                }
                ?>
            </div>
        </div>
    </div>
</li>
